package com.zjj.bams.dao;

import com.zjj.bams.entity.Account;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 */
public class ListDao implements IDao<Account, List<Account>>{

    //集合容器
    private List<Account> accs = new ArrayList<>();

    //初始ID
    private Long id = 100000000000000000L;

    @Override
    public Long getId() {
        return this.id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public boolean insert(Account account) {
        accs.add(account);
        return true;
    }

    @Override
    public Account selectOne(Long id, String password) {
        for (Account acc : accs) {
            if(acc!=null && acc.getId().equals(id) && acc.getPassword().equals(password)){
                return acc;
            }
        }
        return null;
    }

    @Override
    public Account selectOne(Long id) {
        for (Account acc : accs) {
            if(acc!=null && acc.getId().equals(id)){
                return acc;
            }
        }
        return null;
    }

    @Override
    public List<Account> selectAll() {
        return accs;
    }

}
